Skip to content

Only comment out SET statements at the start of a line - #13

Merged
Peter080202 merged 2 commits into
mainfrom
fix-preview-schema-set-null-sed
Sep 7, 2026
Merged

Only comment out SET statements at the start of a line#13
Peter080202 merged 2 commits into
mainfrom
fix-preview-schema-set-null-sed

Conversation

@Peter080202

Copy link
Copy Markdown
Member

Description

The setup-postgres-preview-schema action rewrites the pg_dump output with sed before replaying it into the preview schema. The rule that comments out pg_dump's configuration statements was unanchored and global (s/SET /--SET /g), so it also rewrote every other occurrence of SET in the dump:

  • ... ON DELETE SET NULL;... ON DELETE --SET NULL;
  • ALTER COLUMN "c" SET DEFAULT ...;ALTER COLUMN "c" --SET DEFAULT ...;

-- starts a SQL comment, so the rest of the statement is swallowed and the restore fails with a syntax error (observed in wm-connect-api, whose schema has an ON DELETE SET NULL foreign key: failing run).

How

Anchor the pattern to the start of the line: s/^SET /--SET /. pg_dump only emits its SET configuration statements (statement_timeout, search_path, ...) at column 0, while SET NULL / SET DEFAULT only occur mid-statement on indented lines, so the anchor cleanly separates the two. The g flag is dropped since only one SET can start a line.

@Peter080202 Peter080202 self-assigned this Sep 7, 2026

@ThoSap ThoSap left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌🏼

Comment thread setup-postgres-preview-schema/job-template.yml Outdated
Co-authored-by: Thomas Sapelza <thomas.sapelza@aboutbits.it>
@Peter080202
Peter080202 merged commit 045f1f6 into main Sep 7, 2026
@Peter080202
Peter080202 deleted the fix-preview-schema-set-null-sed branch September 7, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants